﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Micronet.OpenWeb.Com.BLL;
using Micronet.OpenWeb.Com.Controls;
using Micronet.OpenWeb.Utils;

namespace Micronet.OpenWeb.TuyenDung.Admin.Views.Shared
{
    public partial class JobAdmin : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void IsEnabledCheckBox_CheckedChanged(object sender, EventArgs e)
        {
           
            //var obj = OwJobsBLL.OwGetEntity(jobGrid.SelectedValue.OwToInt64TryParseReturn0());
            //obj.IsEnabled = isEnabledCheckBox.Checked.ToString().OwToBoolean();
          //  Response.Write( jobGrid.SelectedItems[0].OwnerTableView.DataKeyValues);
          //RadGrid1.SelectedItems[0].OwnerTableView.DataKeyValues[RadGrid1.SelectedItems[0].ItemIndex][ "CustomerID"]
            //obj.EditingUser = Guid.Empty;
            //if (OwJobsBLL.OwSave(obj) > 0)
            //{

            //    jobGrid.Rebind();
            //    Alert();
            //}
        }

        protected void IsHomeDisplayCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            var isHomeDisplayCheckBox = (OwCheckBox)sender;
            var obj = OwJobsBLL.OwGetEntity(isHomeDisplayCheckBox.Text.Trim().OwToInt64TryParse());
            obj.IsHomeDisplay = isHomeDisplayCheckBox.Checked.ToString().OwToBoolean();
            obj.EditingUser = Guid.Empty;
            if (OwJobsBLL.OwSave(obj) > 0)
            {
                jobGrid.Rebind();
                Alert();
            }
        }

        protected void IsHotCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            var isHotCheckBox = (OwCheckBox)sender;
            var obj = OwJobsBLL.OwGetEntity(isHotCheckBox.Text.Trim().OwToInt64TryParse());
            obj.IsHot = isHotCheckBox.Checked.ToString().OwToBoolean();
            obj.EditingUser = Guid.Empty;
            if (OwJobsBLL.OwSave(obj) > 0)
            {
                jobGrid.Rebind();
                Alert();
            }
        }

        protected void IsDraftCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            var isDraftCheckBox = (OwCheckBox)sender;
            var obj = OwJobsBLL.OwGetEntity(isDraftCheckBox.Text.Trim().OwToInt64TryParse());

            obj.EditingUser = Guid.Empty;
            if (OwJobsBLL.OwSave(obj) > 0)
            {
                jobGrid.Rebind();
                Alert();
            }
        }

        protected void IsDeletedCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            var isDeletedCheckBox = (OwCheckBox)sender;
            var obj = OwJobsBLL.OwGetEntity(isDeletedCheckBox.Text.Trim().OwToInt64TryParse());
            obj.IsDeleted = isDeletedCheckBox.Checked.ToString().OwToBoolean();
            obj.DeletingUser = Guid.Empty;
            if (OwJobsBLL.OwSave(obj) > 0)
            {
                jobGrid.Rebind();
                Alert();
            }
        }

        protected void IsAprrovedCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            var isAprrovedCheckBox = (OwCheckBox)sender;
            var obj = OwJobsBLL.OwGetEntity(isAprrovedCheckBox.Text.Trim().OwToInt64TryParse());
            obj.IsApproved = isAprrovedCheckBox.Checked.ToString().OwToBoolean();
            obj.EditingUser = Guid.Empty;
            if (OwJobsBLL.OwSave(obj) > 0)
            {
                jobGrid.Rebind();
                Alert();
            }
        }
        protected void Alert()
        {
            //MessageNotification.Text = Resources.OpenWeb.ItemUpdateSuccessfullyLabel;
            //MessageNotification.Title = Resources.OpenWeb.ItemUpdateSuccessfullyLabel;
            //MessageNotification.Show();
        }
    }
}